package stackoverflow.domain.question;

import java.util.HashSet;
import java.util.Set;

import stackoverflow.domain.user.User;
import stackoverflow.domain.user.UserUtility;


public class PostUtility
{
	private static User postedByUser = UserUtility.createNewUser("postUtilityUserName", "postUtilityUserPassword");
	private static Set<Tag> tags = new HashSet<Tag>();
	private static String postText ="testPostText";
	private static String tag="testTag";
	
	public static Question createQuestionWithTags(Set<Tag> tags)
	{
		Question.QuestionBuilder questionBuilder = 
			new Question.QuestionBuilder(postedByUser).addTags(tags).postText(postText);
		return questionBuilder.build();
	}

	public static Question createQuestion(String userName, String password, 
			String tag,	String postText)
	{
		User user =UserUtility.createNewUser(userName, password);
		tags.add(new Tag(tag));		

		Question.QuestionBuilder questionBuilder = 
			new Question.QuestionBuilder(user).addTags(tags).postText(postText);
		return questionBuilder.build();
	}
	
	public static Question createQuestion(User user)
	{
		tags.add(new Tag(tag));		

		Question.QuestionBuilder questionBuilder = 
			new Question.QuestionBuilder(user).addTags(tags).postText(postText);
		return questionBuilder.build();
	}

	public static Question createQuestionWithUserAndTags(User user, Set<Tag> tags)
	{
		Question.QuestionBuilder questionBuilder = 
			new Question.QuestionBuilder(user).addTags(tags).postText(postText);
		return questionBuilder.build();
	}

	public static Set<Tag> createTags(String... tagNames) {
		Set<Tag> tags = new HashSet<Tag>();
		for(String tagName : tagNames)
		{
			tags.add(new Tag(tagName));
		}
		return tags;
	}
}
